const server = require('./server');
const pluginHapiPagination = require('./plugins/hapi-pagination');
const hapiAuthJWT2 = require('hapi-auth-jwt2');
const pluginHapiAuthJWT2 = require('./plugins/hapi-auth-jwt2');
const route = require('./routes');
// 引入自定义的 hapi-swagger 插件配置
const pluginHapiSwagger = require('./plugins/hapi-swagger');
const pluginGood = require('./plugins/hapi-good')

const init = async () => {
    await server.register([
    // 为系统使用 hapi-swagger
        ...pluginHapiSwagger,
        pluginHapiPagination,
        hapiAuthJWT2,
        ...pluginGood
    ]);
    pluginHapiAuthJWT2(server);
    // 添加服务器路由
    route.forEach(function (api) {
        server.route(api);
    });

    // 启动服务
    await server.start();
    console.log(`Server running at: ${server.info.uri}`);
};
init();
